/**
 * @version 2007-5-4
 * @author xalinx at gmail dot com
 */
package org.nanhill.vest.rest;

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.nanhill.vest.component.Component;
import org.nanhill.vest.export.DefaultModelExporter;
import org.nanhill.vest.export.ModelExporter;

/**
 * @version 2007-5-4
 * @author xalinx at gmail dot com
 * 
 */
public class HttpPortal {

	private ModelRouter viewModelCreator;

	private ModelExporter contentExporter = new DefaultModelExporter();

	public void setContentExporter(ModelExporter contentExporter) {
		this.contentExporter = contentExporter;
	}

	public void setViewModelCreator(ModelRouter viewModelCreator) {
		this.viewModelCreator = viewModelCreator;
	}

	public void service(HttpServletRequest req, HttpServletResponse resp) {
		String res = null;
		Operation ope = null;
		Component model = viewModelCreator.create(res, ope);
		try {
			contentExporter.export(model, resp.getWriter());
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}
